<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<ui:composition template="/pages/template/system_template.xhtml">
	<ui:define name="content">
		<div class="div-content">

			<p:growl autoUpdate="true" showDetail="true" showSummary="true"
				life="10000" />

			<div align="center" class="header-title-page">
				Temas
				<p:separator />
			</div>

			<h:form id="frmRemoteCommand">
				<p:remoteCommand name="onloadTabela"
					actionListener="#{temaManagedBean.carregarTabela}" autoRun="true"
					update=":frmTemaDataTable:temaDataTable" />
			</h:form>

			<h:form id="frmTemaDataTable">
				<p:dataTable id="temaDataTable" rows="10"
					rowsPerPageTemplate="10,20,30" paginator="true"
					emptyMessage="Não há registros."
					value="#{temaManagedBean.listaTemas}" var="tema"
					paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">

					<p:column headerText="Título">
						<h:outputText value="#{tema.titulo}" />
					</p:column>

					<p:column headerText="Descrição">
						<h:outputText value="#{tema.descricao}" escape="false" />
					</p:column>

					<p:column headerText="Ações" styleClass="centralizar"
						style="width:10%;">
						<p:commandButton id="btnEdit" title="Editar" icon="ui-icon-wrench"
							style="width:22px; height:22px;"
							oncomplete="dialogEditTema.show()" update=":idDialogEditTema">
							<f:setPropertyActionListener
								target="#{temaManagedBean.temaSelecionado}" value="#{tema}" />
						</p:commandButton>

						<p:commandButton id="btnExc" title="Excluir" icon="ui-icon-trash"
							style="width:22px; height:22px;" disabled="#{tema.quantidadeQuestoes gt 0}"
							oncomplete="dialogExcluirTema.show()"
							update=":idDialogExcluirTema">
							<f:setPropertyActionListener
								target="#{temaManagedBean.temaSelecionado}" value="#{tema}" />
						</p:commandButton>
					</p:column>
				</p:dataTable>

				<p:commandButton value="Adicionar tema" style="margin-top: 10px;"
					oncomplete="dialogCadTema.show()" update=":idDialogCadTema" />

			</h:form>

			<ui:include src="/pages/system/dialog/dialog_cadastrar_tema.xhtml" />

			<ui:include src="/pages/system/dialog/dialog_editar_tema.xhtml" />

			<ui:include src="/pages/system/dialog/dialog_excluir_tema.xhtml" />

		</div>
	</ui:define>
</ui:composition>

</html>